package com.gomore.opple.module.incomeandexpense.adapter;

import android.content.Context;
import android.widget.TextView;

import com.gomore.opple.R;
import com.gomore.opple.common.GlobalConstant;
import com.gomore.opple.utils.BigDecimalUtils;
import com.gomore.opple.utils.DateUtil;
import com.gomore.opple.web.cgform.applybill.entity.TOApplyBillEntity;
import com.gomore.opple.widgets.adapter.CommonAdapter;
import com.gomore.opple.widgets.adapter.ViewHolder;

import java.util.List;

/**
 * Created by asus on 2017/5/25.
 */
public class ApplyProgressAdapter extends CommonAdapter<TOApplyBillEntity> {

    Context mContext;

    public ApplyProgressAdapter(Context context, int layoutId, List<TOApplyBillEntity> toApplyBillEntities) {
        super(context, layoutId, toApplyBillEntities);
        mContext = context;
    }

    @Override
    protected void convert(ViewHolder holder, final TOApplyBillEntity toApplyBillEntity, final int position) {
        if (toApplyBillEntity.getBillType() != null) {
            holder.setText(R.id.type, GlobalConstant.applyType.getNameByType(toApplyBillEntity.getBillType()));
        }
        if (toApplyBillEntity.getBillStates() != null) {
            TextView textView = holder.getView(R.id.state);
            textView.setText(GlobalConstant.ApplyState.getStateNameByCode(toApplyBillEntity.getBillStates()));
            textView.setTextColor(mContext.getResources().getColor(GlobalConstant.ApplyState.getColorByCode(toApplyBillEntity.getBillStates())));
        }
        if (toApplyBillEntity.getCreateDate() != null) {
            holder.setText(R.id.time, DateUtil.fomatforDate(toApplyBillEntity.getCreateDate(), DateUtil.DATE_FORMATTER_1));
        }

        if (toApplyBillEntity.getApplyMoney() != null) {
            holder.setText(R.id.money, BigDecimalUtils.forMate(toApplyBillEntity.getApplyMoney()).toString());
        }
    }
}